package com.hspedu.newData.dmsxl.链表.删除;

import com.hspedu.newData.dmsxl.ds.ListNode;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-27 
 * @Version: 1.0
 */

// todo 不太明白
public class LC82删除排序链表中的重复元素Ⅱ {

    public ListNode deleteDuplicates(ListNode head) {

        ListNode dummy = new ListNode(0,head);
        ListNode cur = dummy;

        while(cur.next != null && cur.next.next != null){
            if (cur.next.val == cur.next.next.val){
                int x = cur.next.val;
                while(cur.next !=null && cur.next.val == x){
                    cur.next = cur.next.next;
                }
            }else {
                cur = cur.next;
            }
        }
        return dummy.next;
    }

}
